<!DOCTYPE html>
<!--
Copyright 2012 Mozilla Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Adobe CMap resources are covered by their own copyright but the same license:

    Copyright 1990-2015 Adobe Systems Incorporated.

See https://github.com/adobe-type-tools/cmap-resources
-->
<html dir="ltr" mozdisallowselectionprint>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>浏览</title>

    <link rel="stylesheet" href="viewer.css" />

    <!-- This snippet is used in production (included from viewer.html) -->
    <script src="../../jquery/jquery-1.11.1.min.js"></script>
    <script src="../../jquery/jquery.params.js"></script>
    <script src="../../template/template.js"></script>

    <script>
      function getRealPath() {
        var curWwwPath = window.document.location.href
        var pathName = window.document.location.pathname
        var pos = curWwwPath.indexOf(pathName)
        var localhostPaht = curWwwPath.substring(0, pos)

        var projectName = pathName.substring(
          0,
          pathName.substr(1).indexOf('/') + 1
        )

        var realPath = localhostPaht + projectName
        return localhostPaht
      }
    </script>

    <script id="filetpl" type="text/html">
      {{if data!="" }} {{each data as obR i}}
      <li>
        <a href="#" onclick="changeUrl('{{obR.filename}}','{{obR.isminio}}')"
          >{{obR.name}}</a
        >
      </li>
      {{/each}} {{/if}}
    </script>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="bkcss/css/style.css" rel="stylesheet" />
  </head>

  <body tabindex="1" class="loadingInProgress">
    <div class="leftv">
      <div class="huibj"></div>
      <div class="shuwapper">
        <div class="tongji_h">
          <div class="tongji_nei">文件列表</div>
        </div>
        <div class="tongji_shu">
          <ul class="ulmenu1" id="wenmulu"></ul>
        </div>
      </div>
      <div class="yincangvb">&nbsp;</div>
    </div>
    <div class="righttable">
      <iframe
        id="pdfViewIframe"
        name="pdfViewIframe"
        style="width: 100%; height: 100%"
        src=""
        frameborder="0"
      ></iframe>
    </div>

    <script src="bkcss/js/jquery.nicescroll.js"></script>
    <script src="bkcss/js/scripts.js"></script>
    <script>
      var baseurl = $.query.get('baseurl') === '/' ? '' : $.query.get('baseurl')
      var pdfs = $.query.get('pdfs')
      var names = $.query.get('names').toString()
      var array = pdfs.split(',')
      var arraynames = names.split(',')
      var pdfsArray = []
      for (var index = 0; index < array.length; index++) {
        const element = array[index]
        const name = arraynames[index]
        pdfsArray.push({ filename: element, isminio: false, name: name })
      }
      var pdffile = pdfsArray[0].filename
      var isminio = pdfsArray[0].isminio
      changeUrl(pdffile, isminio)
      var html = template('filetpl', { data: pdfsArray })
      $('#wenmulu').append(html)

      function changeUrl(filename, isminio) {
        if (!filename.endsWith('.pdf')) {
          window.open(filename)
        }
        sessionStorage.removeItem('viewerfilename')
        sessionStorage.setItem('viewerfilename', filename)
        var newurl =
          baseurl +
          '/pdf-viewer/pdf/web/viewer.html?baseurl=' +
          baseurl +
          '&MUL=true' +
          (isminio === 'true' ? '&isminio=' + isminio : '')
        var id = 'pdfViewIframe'
        if (document.frames) {
          document.frames[id].location.href = newurl
        } else {
          if (document.getElementById(id).contentDocument) {
            document.getElementById(id).contentDocument.location.href = newurl
          } else if (document.frames[id].document) {
            document.frames[id].document.location.href = newurl
          }
        }
      }
    </script>
  </body>
</html>
